<template>
  <div class="gallary" @click="handleGallaryClick">
    <div class="gallary-wrapper">
      <!-- swiper -->
      <swiper :options="swiperOption">
        <swiper-slide v-for="(item,index) of imgs" :key="index" >
          <img :src="item" alt="">
        </swiper-slide>
        <div class="swiper-pagination"  slot="pagination"></div>
      </swiper>
    </div>
  </div>
</template>

<script>
export default {
  name: 'CommonGallary',
  props: {
    imgs: {
      type: Array,
      default () {
        return []
      }
    }
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        paginationType: 'fraction',
        loop: true,
        observeParents: true,
        observer: true
      }
    }
  },
  methods: {
    handleGallaryClick () {
      this.$emit('hideGallary')
    }
  }
}
</script>

<style lang="stylus" scoped>
  .gallary-wrapper >>> img
    width 100%
    height 100%
    object-fit contain
  .gallary-wrapper >>> .swiper-container
    overflow inherit
  .gallary-wrapper >>> .swiper-wrapper
    align-items center
  .gallary
    position fixed
    top 0
    bottom 0
    width 6.4rem
    margin 0 auto
    background rgba(0,0,0,.8)
    display flex
    flex-direction column
    align-items center
    justify-content center
    overflow hidden
    &-wrapper
      width 100%
      // height 0
      // padding-bottom 100%
      .swiper-pagination
        color #fff
        bottom -2rem
</style>
